﻿using AutoMapper;
using BSChuangXu.API.Read.Appicant.Commend.MenuCommend;
using BSChuangXu.API.Read.Appicant.Commend.RoleMenuCommand;
using BSChuangXu.Domain.User;
using BSChuangXu.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace BSChuangXu.API.Read.Controllers
{
    /// <summary>
    /// 角色菜单分配
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoleMenuController : ControllerBase
    {
        public readonly IMediator mediator;
        public RoleMenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 查询菜单名称
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<MenuModel>>> GetMenuName([FromQuery] GetMenuNameCommend request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 反填获取菜单(名称,id)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<RoleMenu>>> GetMenuNameFanTian([FromQuery] GetFanTianCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
